package com.bdqn.wf4.cinprovider.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.bdqn.wf4.cinbase.pojo.Film;
import com.bdqn.wf4.cinbase.service.FilmService;
import com.bdqn.wf4.cinbase.util.PageData;
import com.bdqn.wf4.cinprovider.dao.FilmMapper;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FilmServiceimpl implements FilmService {

    @Resource
    FilmMapper filmMapper;

    @Override
    public PageData<Film> getPageData(String uname, String actstar,
                                      int pageIndex, int pageSize) {
        int from = (pageIndex - 1) * pageSize;
        List<Film> list = filmMapper.getFilms(uname, actstar, from, pageSize);
        int con = filmMapper.FilmCount(uname, actstar);
        PageData<Film> getData = new PageData<Film>(pageIndex, pageSize, con,
                list);
        return getData;
    }

    @Override
    public int update(Film film) {
        // TODO Auto-generated method stub
        return filmMapper.update(film);
    }

    @Override
    public Film getById(int id) {
        // TODO Auto-generated method stub
        return filmMapper.getById(id);
    }

    @Override
    public int uadd(Film film) {
        // TODO Auto-generated method stub
        return filmMapper.uadd(film);
    }
}
